/*
 * Tencent is pleased to support the open source community by making ovCompose available.
 * Copyright (C) 2025 THL A29 Limited, a Tencent company. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.tencent.compose

import androidx.compose.ui.window.ComposeArkUIViewController
//import com.tencent.compose.sample.CompottieSample
import com.tencent.compose.sample.NativeResourceManager
import com.tencent.compose.sample.mainpage.MainPage
import com.tencent.compose.sample.nativeResourceManager
import kotlinx.cinterop.ExperimentalForeignApi
import kotlinx.cinterop.toCValues
import kotlinx.coroutines.initMainHandler
import platform.ohos.napi_env
import platform.ohos.napi_value
import kotlin.experimental.ExperimentalNativeApi
//import dev.icerock.moko.resources.utils.InitOhosResourcesUtils
//import moko.resources.kotlin.NR

import platform.posix.FILE

//@OptIn(ExperimentalStdlibApi::class)
//fun testResources()
//{
//    val str0 = NR.strings.hello_world.getString()
//    println("string key:hello_world value:${str0}")
//
//    val str1 = NR.strings.hello_ohos.getFormatString(listOf("xiaowang", 20u, "good study"))
//    println("string key:hello_world value:${str1}")
//
//    val str2 = NR.plurals.chars_count.getFormatString(2u, listOf(12))
//    println("plural key:chars_count value:${str2}")
//
//    val color = NR.colors.textColor.getColor()
//    println("color key:textColor value:${color.toHexString()}")
//
//    val files = NR.files.some_file.readText()
//    println("files key:some_file value:${files}")
//
//    val imageSize = NR.images.imgxxx_1.getImage().size
//    println("image key:imgxxx_1 value:${imageSize}")
//}

@OptIn(ExperimentalNativeApi::class, ExperimentalForeignApi::class)
@CName("MainArkUIViewController")
fun MainArkUIViewController(env: napi_env): napi_value {
    initMainHandler(env)
//    InitOhosResourcesUtils(env)
//    testResources()
    return ComposeArkUIViewController(env) {
        MainPage()
//        CompottieSample()
    }
}

@OptIn(ExperimentalForeignApi::class)
fun initResourceManager(resourceManager: NativeResourceManager) {
    nativeResourceManager = resourceManager
}

